package com.jtpay.payresulthelper.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class AliPayQueryModel implements Parcelable {
    public static final Parcelable.Creator<AliPayQueryModel> CREATOR = new Parcelable.Creator<AliPayQueryModel>() {
        @Override
        public AliPayQueryModel createFromParcel(Parcel source) {
            return new AliPayQueryModel(source);
        }

        @Override
        public AliPayQueryModel[] newArray(int size) {
            return new AliPayQueryModel[size];
        }
    };
    long startTime; //开始时间 格式为查询时间的时间戳
    long endTime;   //结束时间 格式为查询时间的时间戳
    String dateType; //一天的话，值是day,其它的话待查
    private static SimpleDateFormat simpleDateFormat =
            new SimpleDateFormat("yyyyMMdd", Locale.getDefault());

    public AliPayQueryModel() {
    }

    protected AliPayQueryModel(Parcel in) {
        this.startTime = in.readLong();
        this.endTime = in.readLong();
        this.dateType = in.readString();
    }

    public long getStartTime() {
        return startTime;
    }

    public String getStartTimeFormat() {
        Date date = new Date(startTime);
        return simpleDateFormat.format(date);
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public String getEndTimeFormat() {
        Date date = new Date(endTime);
        return simpleDateFormat.format(date);
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public String getDateType() {
        return dateType;
    }

    public void setDateType(String dateType) {
        this.dateType = dateType;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.startTime);
        dest.writeLong(this.endTime);
        dest.writeString(this.dateType);
    }
}
